<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class User extends CI_Model {

    public function validate($username, $password) {
        $this->db->where('username', $username);
        $this->db->where('password', $password);
        $query = $this->db->get('users');

        if ($query->num_rows() > 0) {
            return $query->row();
        } else {
            return null;
        }
    }
    
    public function get_all() {
        $query = $this->db->get('users');
        
        return $query->result_array();
    }
    
    public function get($id) {
        $this->db->where('id', $id);
        $query = $this->db->get('users');
        
        return $query->row();
    }

}
